package com.reliable.service.enums;

/**
 * 上传记录状态枚举
 */
public enum UploadRecordStatus {
    /**
     * 处理中
     */
    PROCESSING(1, "处理中"),

    /**
     * 成功
     */
    SUCCESS(2, "成功"),

    /**
     * 失败
     */
    FAILED(3, "失败"),

    /**
     * 部分成功
     */
    PARTIAL_SUCCESS(4, "部分成功");

    private final Integer code;
    private final String description;

    UploadRecordStatus(Integer code, String description) {
        this.code = code;
        this.description = description;
    }

    public Integer getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    /**
     * 根据code获取枚举对象
     *
     * @param code 状态码
     * @return 对应的枚举对象
     */
    public static UploadRecordStatus fromCode(Integer code) {
        for (UploadRecordStatus status : UploadRecordStatus.values()) {
            if (status.getCode().equals(code)) {
                return status;
            }
        }
        throw new IllegalArgumentException("无效的状态码: " + code);
    }
}